#ifndef INPUTMANAGER_H
#define INPUTMANAGER_H
#include "common/singleton.h"
#include "common/common.h"
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>

#define DIK_LBUTTON 0x100
#define DIK_RBUTTON 0x101
#define DIK_MBUTTON 0x102

struct KeyInfo
{
	KeyInfo()
	{
		Reset();
	}
	void Reset()
	{
		keyed = false;
		param1 = 0;
		param2 = 0;
	}
	bool keyed;
	int param1;
	int param2;
};

struct InputInfo
{
	KeyInfo MouseWheel;
	KeyInfo LButton;
	KeyInfo RButton;
	POINT GameMouse;
    POINT MapMouse;
    POINT WindowMouse;
    IRect MapAreaMouse;
    char KeyBoard[256];
	void Reset()
	{
		MouseWheel.Reset();
		LButton.Reset();
		RButton.Reset();
        ZeroMemory( KeyBoard, sizeof(KeyBoard) );
		GameMouse.x = 0;
		GameMouse.y = 0;
	}
};

class CInputManager:public CSingleton<CInputManager>
{
    IMPLEMENT_SINGLETON(CInputManager);
public:
    bool Update( uint32 delta );
	const InputInfo &GetInputInfo();
    void Initialize();
    void Reset();
    void ComputeMousePos();

    POINT &GetMousePos();
    bool IsKeyPressed( int key );
    bool IsKeyPressing( int key );
private:
	InputInfo m_inputinfo;
    InputInfo m_lastinputinfo;
    IDirectInputDevice8 *m_pMouse;  
    IDirectInput8 *m_pDI;
    IDirectInputDevice8 *m_pKB;
};
#endif